package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.NoteInfoDao;
import cn.topevery.garden.entity.po.NoteInfo;
import cn.topevery.garden.entity.query.NoteInfoQuery;
import cn.topevery.garden.entity.vo.NoteInfoVO;

import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.DataFillHelper;
import hw.topevery.framework.db.CommandType;
import hw.topevery.framework.db.DataReader;
import hw.topevery.framework.entity.DbCsp;
import hw.topevery.framework.entity.Value;
import hw.topevery.framework.entity.KeyValue;
import hw.topevery.framework.enums.DbTypeEnum;
import hw.topevery.framework.util.LogUtil;
import hw.topevery.framework.db.DbScriptHelper;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.UUID;

/**
 * 操作规范、应急预案、安全教育
 */
@Repository
public class NoteInfoDaoImpl extends BaseDaoImpl<NoteInfo> implements NoteInfoDao {
    @Override
    public <P extends DbCsp> List<NoteInfo> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<NoteInfoVO> listPage(NoteInfoQuery query) {
        String table = "t_note_info tni";

        String columns = "tni.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tni.c_id desc");
        sqlQueryMate
                .where(true, "tni.c_db_status", ScriptConditionEnum.Eq, 0)
                .where(ObjectUtils.isNotEmpty(query.getTypeId()), "tni.c_type_id", ScriptConditionEnum.Eq, query.getTypeId())
                .where(ObjectUtils.isNotEmpty(query.getContent()), "tni.c_content", ScriptConditionEnum.Like, query.getContent())
        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, NoteInfoVO.class);
    }

    @Override
    public NoteInfo getEntityByColumn(String key,String value){
        KeyValue<String> map=new KeyValue<>();
        map.key=key;
        map.value=value;
        return getEntityByColumnEqValue(map);
    }
}
